Hệ thống hiệu sách thương mại điện tử

1 <?php
2 session_start();

3 if
(!isset($_SESSION['user']))
4        header(
"location: index.php?Message=Login To Continue");
5 ?>
6
7
8 <!DOCTYPE html>
9 <html>
10 <meta name=
"viewport" content="width=device-width, initial-scale=1">
11 <link rel=
"stylesheet" href="css/w3.css">
12 <link rel=
"stylesheet" href="css/font-awesome.min.css">
13 <link rel=
"stylesheet" href="css/bootstrap.min.css" type="text/css">
14 <link rel=
"stylesheet" href="css/my.css" type="text/css">
15 <body>
16 <style>
17
18         #books .row{margin-top:30px;font-weight:
800;}
19         @media only screen and (max-width: 760px) { #books .row{margin-top:10px;}}
20         .book-block {margin-top:20px;margin-bottom:10px; padding:10px 10px 10px 10px; border :1px solid #DEEAEE;border-radius:10px;height:
100%;}
21 </style>
22
23 </head>
24
25 <body>
26   <nav
class="navbar navbar-default navbar-fixed-top navbar-inverse">
27     <div
class="container-fluid">
28         <!-- Brand and toggle
get grouped for better mobile display -->
29         <div
class="navbar-header">
30             <button type=
"button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
31                 <span
class="sr-only">Toggle navigation</span>
32                 <span
class="icon-bar"></span>
33                 <span
class="icon-bar"></span>
34                 <span
class="icon-bar"></span>
35              </button>
36             <a
class="navbar-brand" href="index.php" style="padding: 1px;"><img class="img-responsive" alt="Brand" src="img/logo.jpg" style="width: 147px;margin: 0px;"></a>
37         </div>
38
39         <!-- Collect the nav links, forms, and other content
for toggling -->
40         <div
class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
41         <ul
class="nav navbar-nav navbar-right">
42             <?php
43             
if(!isset($_SESSION['user']))
44               {
45                 echo
'
46                 <li>
47                     <button type=
"button" id="login_button" class="btn btn-lg" data-toggle="modal" data-target="#login">Login</button>
48                       <div id=
"login" class="modal fade" role="dialog">
49                         <div
class="modal-dialog">
50                             <div
class="modal-content">
51                                 <div
class="modal-header">
52                                     <button type=
"button" class="close" data-dismiss="modal">&times;</button>
53                                     <h4
class="modal-title text-center">Login Form</h4>
54                                 </div>
55                                 <div
class="modal-body">
56                                   <ul >
57                                     <li>
58                                       <div
class="row">
59                                           <div
class="col-md-12 text-center">
60                                               <form
class="form" role="form" method="post" action="index.php" accept-charset="UTF-8">
61                                                   <div
class="form-group">
62                                                       <label
class="sr-only" for="username">Username</label>
63                                                       <input type=
"text" name="login_username" class="form-control" placeholder="Username" required>
64                                                   </div>
65                                                   <div
class="form-group">
66                                                       <label
class="sr-only" for="password">Password</label>
67                                                       <input type=
"password" name="login_password" class="form-control" placeholder="Password" required>
68                                                       <div
class="help-block text-right">
69                                                           <a href=
"#">Forget the password ?</a>
70                                                       </div>
71                                                   </div>
72                                                   <div
class="form-group">
73                                                       <button type=
"submit" name="submit" value="login" class="btn btn-block">
74                                                           Sign
in
75                                                       </button>
76                                                   </div>
77                                               </form>
78                                           </div>
79                                       </div>
80                                     </li>
81                                   </ul>
82                                 </div>
83                                 <div
class="modal-footer">
84                                     <button type=
"button" class="btn btn-default" data-dismiss="modal">Close</button>
85                                 </div>
86                             </div>
87                         </div>
88                       </div>
89                 </li>
90                 <li>
91                   <button type=
"button" id="register_button" class="btn btn-lg" data-toggle="modal" data-target="#register">Sign Up</button>
92                     <div id=
"register" class="modal fade" role="dialog">
93                       <div
class="modal-dialog">
94                           <div
class="modal-content">
95                               <div
class="modal-header">
96                                   <button type=
"button" class="close" data-dismiss="modal">&times;</button>
97                                   <h4
class="modal-title text-center">Member Registration Form</h4>
98                               </div>
99                               <div
class="modal-body">
100                                 <ul >
101                                   <li>
102                                     <div
class="row">
103                                         <div
class="col-md-12 text-center">
104                                             <form
class="form" role="form" method="post" action="index.php" accept-charset="UTF-8">
105                                                 <div
class="form-group">
106                                                     <label
class="sr-only" for="username">Username</label>
107                                                     <input type=
"text" name="register_username" class="form-control" placeholder="Username" required>
108                                                 </div>
109                                                 <div
class="form-group">
110                                                     <label
class="sr-only" for="password">Password</label>
111                                                     <input type=
"password" name="register_password" class="form-control" placeholder="Password" required>
112                                                 </div>
113                                                 <div
class="form-group">
114                                                     <button type=
"submit" name="submit" value="register" class="btn btn-block">
115                                                         Sign Up
116                                                     </button>
117                                                 </div>
118                                             </form>
119                                         </div>
120                                     </div>
121                                   </li>
122                                 </ul>
123                               </div>
124                               <div
class="modal-footer">
125                                   <button type=
"button" class="btn btn-default" data-dismiss="modal">Close</button>
126                               </div>
127                           </div>
128                       </div>
129                     </div>
130                 </li>
';
131               }
132             
else
133                 echo
' <li> <a href="destroy.php" class="btn btn-lg"> LogOut </a> </li>';
134             ?>
135
136         </ul>
137         </div><!-- /.navbar-collapse -->
138     </div><!-- /.container-fluid -->
139   </nav>
140   <div id=
"top" >
141       <div id=
"searchbox" class="container-fluid" style="width:112%;margin-left:-6%;margin-right:-6%;">
142           <div>
143               <form role=
"search" method="POST" action="Result.php">
144                   <input type=
"text" class="form-control" name="keyword" style="width:80%;margin:20px 10% 20px 10%;" placeholder="Search for a Book , Author Or Category">
145               </form>
146           </div>
147       </div>
148 <?php
149 include
"dbconnect.php";
150 $keyword=$_POST[
'keyword'];
151
152 $query=
"select * from products where PID like '%{$keyword}%' OR Title like '%{$keyword}%' OR Author like '%{$keyword}%' OR Publisher like '%{$keyword}%' OR Category like '%{$keyword}%'";
153 $result=mysqli_query($con,$query) or die(mysqli_error($con));;
154
155     $i=
0;
156     echo
'<div class="container-fluid" id="books">
157         <div
class="row">
158           <div
class="col-xs-12 text-center" id="heading">
159                  <h4 style=
"color:#00B9F5;text-transform:uppercase;"> found '. mysqli_num_rows($result) .' records </h4>
160            </div>
161         </div>
';
162         
if(mysqli_num_rows($result) > 0)
163         {
164             
while($row = mysqli_fetch_assoc($result))
165             {
166             $path=
"img/books/" .$row['PID'].".jpg";
167             $description=
"description.php?ID=".$row["PID"];
168             
if($i % 3 == 0) $offset= 0;
169             
else $offset= 1;
170             
if($i%3==0)
171             echo
'<div class="row">';
172             echo
'
173                <a href=
"'.$description.'">
174                 <div
class="col-sm-5 col-sm-offset-1 col-md-3 col-md-offset-'.$offset.' col-lg-3 text-center w3-card-8 w3-dark-grey">
175                     <div
class="book-block">
176                         <img
class="book block-center img-responsive" src="'.$path.'">
177                         <hr>
178                          
' . $row["Title"] . '<br>
179                         
' . $row["Price"] .' &nbsp
180                         <span style=
"text-decoration:line-through;color:#828282;"> ' . $row["MRP"] .' </span>
181                         <span
class="label label-warning">'. $row["Discount"] .'%</span>
182                     </div>
183                 </div>
184                 
185                </a>
';
186             $i++;
187             
if($i%3==0)
188             echo
'</div>';
189             }
190         }
191     echo
'</div>';
192 ?>
193
194
195 </body>
196 </html>


Gõ tìm kiếm nhanh...